home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / program / vgatx10s.zip / VGADEMO.CPP < prev    next >
C/C++ Source or Header  |  1997-04-12  |  4KB  |  130 lines

  1. /*
  2.  * This file is part of the VgaText C++ Programming Library
  3.  *
  4.  * Copyright (c) 1995, 1997 by Branislav L. Slantchev
  5.  * A fine product of Silicon Creations, Inc. (gargoyle)
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the License which accompanies this
  9.  * software. This library is distributed in the hope that it will
  10.  * be useful, but without any warranty; without even the implied
  11.  * warranty of merchantability or fitness for a particular purpose.
  12.  *
  13.  * You should have received a copy of the License along with this
  14.  * library, in the file LICENSE.DOC; if not, write to the address
  15.  * below to receive a copy via electronic mail.
  16.  *
  17.  * You can reach Branislav L. Slantchev (Silicon Creations, Inc.)
  18.  * at bslantch@cs.angelo.edu. The file SUPPORT.DOC has the current
  19.  * telephone numbers and the postal address for contacts.
  20. */
  21. #include "vgatext.h"
  22. #include <conio.h>
  23.  
  24. void ShowText(const char *aText);
  25. void ShowNoPrompt(const char *aText);
  26.  
  27. void main()
  28. {
  29.     zVgaText vga;
  30.     int i;
  31.  
  32.     if( !vga.Detect() ){
  33.         cprintf("VGA is *required* for this to work...");
  34.         return;
  35.     }
  36.     // fade in the whole screen (set the original palette to 0)
  37.     for( i = 0; i < 16; ++i ) vga.SetColor(i, "\x00\x00\x00");
  38.     vga.LoadPalettes();
  39.     ShowNoPrompt("This text was invisible and then came up");
  40.     vga.ResetPalettes();
  41.     vga.FadeIn();
  42.     cprintf("press a key...");
  43.     getch(); clrscr();
  44.  
  45.     //pulse reds and greens (normal and bright)
  46.     vga.ResetPalettes();
  47.     vga.PulseColor(2, 2);
  48.     vga.PulseColor(10, 2);
  49.     vga.PulseColor(4, 2);
  50.     vga.PulseColor(12, 2);
  51.     vga.LoadPalettes();  // required to transfer the palettes to the DAC
  52.     vga.enable(); // enable the interrupt intercept
  53.     // now anything green or red should be pulsing
  54.     ShowText("Green and red should be pulsing");
  55.  
  56.     vga.disable(0); // disable the interrupt
  57.     vga.ResetPalettes();
  58.     vga.GradeColor(2, "\x3F\x00\x00");
  59.     vga.LoadPalettes();
  60.     vga.enable();
  61.     ShowText("This grades green from normal to high red");
  62.  
  63.     vga.disable();
  64.     vga.ResetPalettes();
  65.     for( i = 0; i < 16; ++i ) vga.PulseColor(i, 2);
  66.     vga.LoadPalettes();
  67.     vga.enable();
  68.     ShowText("All 16 attributes should be pulsing now");
  69.  
  70.     vga.disable();
  71.     vga.ResetPalettes();
  72.     vga.SetColor(2, "\x3F\x00\x00", 8, 15);
  73.     vga.LoadPalettes();
  74.     vga.enable();
  75.     ShowText("This changes green to red instantly");
  76.  
  77.     vga.disable();
  78.     vga.ResetPalettes();
  79.     vga.GradeColor(3, "\x00\x00\x00");
  80.     vga.LoadPalettes();
  81.     vga.enable();
  82.     ShowText("This fades low cyan to black");
  83.  
  84.     vga.disable();
  85.     vga.ResetPalettes();
  86.     vga.SetColor(14, "\x00\x00\x00", 0, 14);
  87.     vga.SetColor(14, "\x3F\x3F\x00", 15, 15); // max yellow
  88.     vga.SetColor(1,  "\x00\x00\x3F", 15, 15); // max blue
  89.     vga.SetDelta(1);
  90.     vga.LoadPalettes();
  91.     vga.enable();
  92.     ShowText("Look at the yellow strobe and the blue beacon");
  93.  
  94.     vga.disable();
  95.     vga.ResetPalettes();
  96.     vga.GradeColor(3, "\x00\x00\x00", 0, 7);
  97.     vga.BlinkSim(3);
  98.     vga.LoadPalettes();
  99.     vga.enable();
  100.     ShowText("This is 'softened' blink for cyan");
  101.  
  102.     vga.disable();
  103.     vga.ResetPalettes();
  104.     ShowText("This will fade out the moment you press a key.");
  105.     vga.FadeOut();
  106.     clrscr();
  107. }
  108.  
  109.  
  110. void
  111. ShowText(const char *aText)
  112. {
  113.     ShowNoPrompt(aText);
  114.     textattr(15);
  115.     cprintf("\n\r\n\rpress a key...");
  116.     getch();
  117. }
  118.  
  119. void ShowNoPrompt(const char *aText)
  120. {
  121.     int i;
  122.  
  123.     clrscr();
  124.     cprintf("%s\n\r\n\r", aText);
  125.     for( i = 0; i < 16; ++i ){
  126.         textattr(i);
  127.         cprintf("    sample for color 0x%02X\n\r", i);
  128.     }
  129. }
  130.